<?php


namespace app\yinerda\controller;


use app\BaseController;

class Test extends BaseController
{
    public function test(){
        $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http';
        $host = $_SERVER['HTTP_HOST']; // 例如: www.example.com
        $port = $_SERVER['SERVER_PORT']; // 例如: 80
        $currentUrl = $protocol . '://' . $host; // 例如: http://www.example.com
        if ($port != 80 && $port != 443) { // 非标准端口
            $currentUrl .= ':' . $port; // 例如: http://www.example.com:8080
        }
        echo $currentUrl;
    }
    public function index(){
        $path=dir(getcwd())->path.'/log/yinerda/'.date('Ymd');
        if (! file_exists ( $path )) {
            mkdir ( "$path", 0777, true );
        }
        $address = $path."/".date('His').rand(100000,999999).'.txt';
        file_put_contents($address,file_get_contents("php://input"),FILE_APPEND);
    }

}